package com.hellohoper.script.config.api.app.resources;

import com.hellohoper.script.config.admin.app.dao.pojo.ScriptConfig;
import com.hellohoper.script.config.api.app.service.ScriptConfigService;
import com.hellohoper.script.config.api.feign.ScriptConfigFeign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 配置查询服务
 * Created by hk on 17/8/19.
 */
@RestController
@RequestMapping("/config/api")
public class ScriptConfigResource implements ScriptConfigFeign {

    private static final Logger LOGGER = LoggerFactory.getLogger(ScriptConfigResource.class);

    @Autowired
    private ScriptConfigService scriptConfigService;

    @RequestMapping("/search")
    @Override
    public ScriptConfig searchConfig(String appName, String scriptName) {
        LOGGER.info("searchConfig by appName:" + appName + " scriptName:" + scriptName);
        return scriptConfigService.selectScriptConfig(appName, scriptName);
    }

    @RequestMapping("/searchList")
    @Override
    public List<ScriptConfig> searchConfig(String appName) {
        LOGGER.info("searchConfig by appName:" + appName);
        return scriptConfigService.selectScriptConfigList(appName);
    }
}
